#include <iostream>
#include<vector>
using namespace std;
struct unique_found
{
    vector<int> parents;
    vector<int> size;
    int maxsize;
    unique_found(int n)
    {
        parents.resize(n);
        size.resize(n,1);
        maxsize = 1;
        for(int i = 0;i<parents.size();i++)
        {
            parents[i] = i;
        }
    }
    int find(int x)
    {
        while(parents[x]!=x)
        {
            parents[x] = parents[parents[x]];
            x = parents[x];
        }
        return x;
    }
    int unique_merge(int x,int y)
    {
        int rootx = find(x);
        int rooty = find(y);
        if(rootx==rooty)
        {
            return rootx;
        }
        if(size[rootx]<size[rooty])
        {
            swap(rootx,rooty);
        }
        parents[rooty] = rootx;
        size[rootx] += size[rooty];   
        maxsize = max(maxsize, size[rootx]); 
        return rootx;
    }
    void clear()
    {
        int n = parents.size();
        fill(size.begin(), size.end(), 1);
        for (int i = 0; i < n; ++i) {
            parents[i] = i;
        }
        maxsize = 1;
    }
};

int main() 
{
    int T;
    cin>>T;
    for(int i = 0;i<T;i++)
    {
        int n = 0;
        cin>>n;
        unique_found my_found(1000000);
        for(int j = 0;j<n;j++)
        {
            int x;int y;
            cin>>x>>y;
            my_found.unique_merge(x,y);
        }
        cout<<my_found.maxsize<<endl;
    }
}
// 64 位输出请用 printf("%lld")